<template>
  <!--  -->
  <div class="container">
    <el-form ref="search" :inline="true" :model="formInline" class="search" label-width="100px" size="small">
      <el-form-item label="人员姓名">
        <el-input v-model="formInline.user" placeholder="请输入名称" />
      </el-form-item>
      <el-form-item label="人员类型:">
        <el-select v-model="formInline.type">
          <el-option v-for="item in type" :key="item.type" :label="item.type" :value="item.value" />
        </el-select>
      </el-form-item>
      <el-form-item label="移入原因:">
        <el-input v-model="formInline.reason" placeholder="请输入移入原因" />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" size="mini" @click="onSubmit">查询</el-button>
        <el-button type="primary" size="mini" @click="handlePerson">人员轨迹</el-button>
      </el-form-item>
    </el-form>
    <div class="table-wrap">
      <div class="f-betweenX table-header">
        <div class="table-title">
          <svg-icon icon-class="table_menu" class-name="icon-table" />
          <!-- 查询结果 共找到 <span class="count">1006</span> 条符合的记录{{ maxTableHeight }} -->
          查询结果 共找到 <span class="count">4</span> 条符合的记录
        </div>
        <div class="table-control">
          <el-button type="primary" size="mini" icon="el-icon-plus" plain @click="handleAdd">
            新增
          </el-button>
        </div>
      </div>
      <!-- 表格 -->
      <el-table :data="tableData" stripe style="width: 100%" border>
        <el-table-column prop="name" label="人员姓名" sortable resizable show-overflow-tooltip align="center" />
        <el-table-column prop="type" label="人员类型" resizable show-overflow-tooltip align="center" />
        <el-table-column prop="date" label="移入时间" resizable show-overflow-tooltip align="center" />
        <el-table-column prop="reason" label="移入原因" resizable show-overflow-tooltip align="center" />
        <el-table-column fixed="right" label="操作" width="400" show-overflow-tooltip resizable align="center">
          <template slot-scope="scope">
            <el-button size="mini" type="warning" plain @click="handleEdit( scope.row)">
              修改
            </el-button>
            <el-button size="mini" type="danger" plain @click="handleDelete(scope.row)">
              删除
            </el-button>
          </template>
        </el-table-column>
      </el-table>
      <!-- 分页 -->
      <el-pagination :current-page="query.page" :page-sizes="query.sizes" :page-size="query.size" layout="total, sizes, prev, pager, next, jumper" :total="total" @size-change="handleSizeChange" @current-change="handleCurrentChange" />
    </div>

    <!-- 新增 -->
    <add ref="add" />

    <!-- 修改对话框 -->
    <el-dialog title="修改" :visible.sync="editDialog" width="25%">
      <el-form :model="editForm" label-width="80px">
        <el-form-item label="人员姓名">
          <el-input v-model="editForm.name" disabled />
        </el-form-item>
        <el-form-item label="人员类型">
          <el-input v-model="editForm.type" />
        </el-form-item>
        <el-form-item label="移入原因">
          <el-input v-model="editForm.reason" />
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="editDialog = false">取 消</el-button>
        <el-button type="primary" @click="editDialog = false">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
// import Pagination from './Pagination.vue'
import tableHeight from '@/mixins/tableHeight'
import Add from './Add'
// import TreeSelect from '@/components/TreeSelect'

export default {
  components: {
    // Pagination,
    Add
    // TreeSelect
  },
  mixins: [tableHeight],
  data() {
    return {
      // 查询的表单
      formInline: {
        user: '',
        type: '',
        reason: ''
      },
      officeTreeList: this.$config.treeList, // 树形结构数据,
      // 人员类型
      type: [
        {
          type: '访客',
          value: '访客'
        },
        {
          type: '内部人员',
          value: '内部人员'
        },
        {
          type: '可疑人员',
          value: '可疑人员'
        },
        {
          type: '其他人员',
          value: '其他人员'
        }
      ],
      // 表格数据
      tableData: [
        {
          name: '王小虎',
          type: '内部人员',
          date: '2022-02-03',
          reason: '个人'
        },
        {
          name: '王二虎',
          type: '可疑人员',
          date: '2022-02-13',
          reason: '个人'
        },
        {
          name: '王大虎',
          type: '访客',
          date: '2022-02-12',
          reason: '个人'
        },
        {
          name: '王虎',
          type: '其他人员',
          date: '2022-02-07',
          reason: '个人'
        }
      ],
      // 修改表单
      editForm: {
        name: '',
        type: '',
        reason: ''
      },
      // 修改弹框
      editDialog: false,
      // 分页器
      query: {
        page: 1,
        size: 10,
        sizes: [5, 10, 20]
      },
      total: 4
    }
  },
  methods: {
    // 改变条数
    handleSizeChange() {

    },
    // 改变页码
    handleCurrentChange() {

    },

    onSubmit() {
      console.log('submit!')
    },
    // 新增
    handleAdd() {
      this.$refs.add.toggleAdd(true)
    },
    // // 获取部门名称
    // popoverHide(checkedIds, checkedData, el) {
    //   if (el) {
    //     eval(' ( this.' + el + ' = checkedIds) ')
    //     console.log(1, this.formInline.deptId)
    //   }
    // }

    handlePerson() {
      this.$router.push({
        name: 'BlackListRoute'
      })
    },

    // 修改
    handleEdit(row) {
      this.editDialog = true
    },

    // 删除
    handleDelete() {
      // 确认是否删除
    }
  }
}
</script>

<style lang="scss" scoped>
.container {
  padding: 0 17px;
  .search {
    padding-top: 16px;
  }
  .table-wrap {
    .icon-table {
      margin: 0 10px;
    }
    .table-header {
      height: 52px;
      background: #f6f7f9;
      border: 1px solid #e1e7e9;
      border-bottom: none;
      font-size: 16px;
      color: #494949;
      line-height: 52px;
      border-radius: 4px 4px 0 0;
      .count {
        color: rgb(235, 104, 84);
      }
      .table-control {
        margin-right: 10px;
      }
    }
  }
  .pagination-wrap {
    height: 80px;
    .pagination {
      display: inline-block;
    }
  }
}
</style>

<style lang="scss">
.tree-line {
  .el-tree-node {
    position: relative;
    padding-left: 16px; // 缩进量
  }
  .el-tree-node__children {
    padding-left: 16px; // 缩进量
  }

  // 竖线
  .el-tree-node::before {
    content: '';
    height: 100%;
    width: 1px;
    position: absolute;
    left: -3px;
    top: -26px;
    border-width: 1px;
    border-left: 1px dashed #52627c;
  }
  // 当前层最后一个节点的竖线高度固定
  .el-tree-node:last-child::before {
    height: 38px; // 可以自己调节到合适数值
  }

  // 横线
  .el-tree-node::after {
    content: '';
    width: 24px;
    height: 20px;
    position: absolute;
    left: -3px;
    top: 12px;
    border-width: 1px;
    border-top: 1px dashed #52627c;
  }

  // 去掉最顶层的虚线，放最下面样式才不会被上面的覆盖了
  & > .el-tree-node::after {
    border-top: none;
  }
  & > .el-tree-node::before {
    border-left: none;
  }

  // 展开关闭的icon
  .el-tree-node__expand-icon {
    font-size: 16px;
    // 叶子节点（无子节点）
    &.is-leaf {
      color: transparent;
      // display: none; // 也可以去掉
    }
  }
}
.el-pagination {
  margin-left: 40%;
  margin-top: 30px;
}
</style>
